<template>
	<view>
		<bg-video></bg-video>
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block class="text-white" slot="content">教练申请</block>
		</cu-custom>
		
		<!-- 教练申请列表 -->
		<view class="">
			<view class="cu-list menu- card-menu">
				<view class="cu-item bg-white shadow rounded margin-top" v-for="(sq, index) in jlsqs" :key="index">					
					<view class="bg-white padding-sm flex justify-between">
						<text>教练名称：</text>
						<text class="text-black">{{sq.mdjlname}}</text>
					</view>
					
					<view class="bg-white padding-sm flex justify-between">
						<text>申请门店：</text>
						<text class="text-black">{{sq.mdname}}</text>
					</view>
					
					<view class="bg-white padding-sm flex justify-between">
						<text>申请日期：</text>
						<text class="text-black">{{sq.ct}}</text>
					</view>
					
					<view class="flex justify-end padding-sm">
						<button size="mini" class="bg-blue margin-0" @tap="setSq(sq.mdjlsqid, 'Y', index)">同意</button>
						<button size="mini" class="bg-red margin-0 margin-left-sm" @tap="setSq(sq.mdjlsqid, 'N', index)">拒绝</button>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 显示更多按钮 -->
		<view class="flex justify-center margin-top-lg margin-bottom-xl" v-if="jlsqs.length < pageInfo.total">
			<button class="cu-btn bg-white shadow round" @tap="loadMore">
				<text class="text-blue">显示更多</text>
			</button>
		</view>
		<view class="text-center" v-if="jlsqs.length == 0">
			<text class="text-gray">暂无记录</text>
		</view>
	</view>
</template>

<script>
	export default {
		data: function() {
			return {
				pageInfo: {
					current: 1,
					size: 16,
					total: 0
				},
				jlsqs: []
			}
		},
		onLoad: function() {
			this.search();
		},
		methods : {
			search: function() {
				this.jlsqs = [];
				this.loadSqs();
			},
			loadMore: function() {
				this.pageInfo.current++;
				this.loadSqs();
			},
			setSq: function(mdjlsqid, flg, index) {
				this.api("/mdjl/sq/delete").send({
					mdjlsqid,
					flg,
				}).then(data => {
					this.message.info("提交成功");
					this.jlsqs = this.jlsqs.splice(index, 1);
					this.$forceUpdate();
				});
			},
			loadSqs: function() {
				let param = {
					current: this.pageInfo.current,
					size: this.pageInfo.size,
					dzid: this.store.state.dz.dzid,
				};
				this.api("/mdjl/sq/page").send(param).then(data => {
					this.pageInfo.current = data.sqs.current;
					for (let index in data.sqs.records) {
						let record = data.sqs.records[index];
						this.jlsqs.push(record);
					}
				});
			}
		}
	}
</script>

<style>
</style>